<template>
  <div class="list-content pages">
    <Top></Top>
    <Nav></Nav>
    <div class="listContent" v-loading="searchLoading">
      <div class="site">当前位置：在线搜索</div>
      <div class="list-item"  @click="skip(item.id)" v-for="item in newList" :key="item.id" >
        <div class="title">{{item.title}}</div>
        <div class="data">{{item.create_time}}</div>
      </div>
    </div>
    <Bottom></Bottom>
  </div>
</template>

<script>
import {getNoticeListApi} from "@/api/spotlight";
import Top from '@/components/Top.vue'
import Nav from '@/components/Nav.vue'
import Bottom from '@/components/Bottom.vue'
import {createParams} from "@/utils/utils";

export default {
  name: "List",
  data(){
    return{
      searchLoading:false,
      page:1,
      limit:15,
      category_id:0,
      newList:[],
      title:'',
    }
  },
  watch:{//监听
    title:{
      handler(val){
        this.getList()
      }
    },
    "$route":{
      handler(val){
        createParams(this,this.$route.query)
      },
      immediate:true
    }
  },
  methods:{
    getList() {
      this.searchLoading = true
      getNoticeListApi({page:this.page,limit:this.limit,category_id:this.category_id,title:this.title}).then((res) => {
        this.newList = res.result.list;
        this.count = res.result.count
      }).finally(()=>{
        this.searchLoading = false
      })
    },
    skip(id){
      this.$router.replace({ name: 'spotlightDetail',query:{id:id} })
    },
  },
  components: {
    Top,
    Nav,
    Bottom,
  },
}
</script>

<style lang="scss" scoped>
.list-content{
  .listContent{
    width: 1220px;
    margin: 30px auto;
    padding-left: 20px;
    .site{
      color: #797770;
    }
    .list-item{
      width: 100%;
      height: 40px;
      display: flex;
      align-items: center;
      cursor: pointer;
      .title{
        width: 70%;
        font-size: 18px;
      }
      .data{
        width: 30%;
        text-align: right;
        font-size: 18px;
      }
    }
  }

}
</style>
